
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:yybb_flutter/Macros/yyb_macros.dart';

import 'incrementai_cule_potentia_page.dart';
import 'incrementai_search_costomer_page.dart';

class IncrementalBoradPage extends StatefulWidget {
  IncrementalBoradPage({Key key, this.params}) : super(key: key);
  Map<dynamic, dynamic> params;
  @override
  _IncrementalBoradPageState createState() {
    return _IncrementalBoradPageState();
  }
}

class _IncrementalBoradPageState extends State<IncrementalBoradPage> with TickerProviderStateMixin {
  List<Tab> _tabs;
  TabController _tabController;
  Widget _tabContent;
  int _currentIndex = 0;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController = TabController(vsync: this, length: 2);
    _tabController.addListener(() => _onTabChanged());
    //初始化_tabs;
    _tabs = [
      Tab(text: '潜在客户'),
      Tab(text: '线索客户'),
    ];
  }

  @override
  void dispose() {
    // TODO: implement dispose
    _tabController.removeListener(_onTabChanged);
    _tabController.dispose();
    super.dispose();
  }


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      color: Colors.white,
      home: Scaffold(
        backgroundColor: Colors.white,
        appBar: AppBar(
          backgroundColor: Colors.white,
          leading: IconButton(
            icon:
            ImageIcon(
              AssetImage("images/public/app_back_btn@3x.png"),
              size: 17,
              color: Colors.black,
            ),

            onPressed: (){
              FlutterBoost.singleton
                  .close("incrementalBoradPage",
                  exts: {"animated": true});
            },
          ),
          shadowColor:Colors.transparent,
          title:Text(
            "覆盖率增量看板",
            style: TextStyle(
                color: Colors.black
            ),
          ),
          bottom: PreferredSize(
            preferredSize: Size.fromHeight(45),
            child:  Column(
              children: [
                Container(
                  color: Colors.white,
                  //tabs背景色
                  child: TabBar(
                    indicatorWeight: 1.5,
                    // indicatorColor:Colors.red,
                    indicatorSize: TabBarIndicatorSize.label,
                    controller: _tabController,
                    labelColor: YYBBColorBlue,
                    labelStyle:
                    TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
                    unselectedLabelColor: YYBBColor119,
                    tabs: _tabs,
                    indicatorColor: Theme.of(context).primaryColor,
                  ),
                ),
              ],
            ),
          ),
        ),
        body:WillPopScope(
          onWillPop: () async => false,
          child: TabBarView(
                  controller: _tabController,
                  children: <Widget>[
                    IncrementaiCulePage(),
                    IncrementaiSearchCustomerPage(),
                  ],
                ),
        ),
      ),
    );
  }

  /*
    底部导航点击事件
    */
  _onTabChanged() {
    if (_tabController.indexIsChanging) { //判断是否是选中位置发生变化
      if (this.mounted) { //判断组件是否已被挂载
        this.setState(() {
          switch (_tabController.index) {
            case 0:
              break;
            case 1:
              break;
          }
          _currentIndex = _tabController.index;
        });
      }
    }
  }
}
